/*
 *      proc_view.h
 *      
 *      Copyright 2009 AzureSky <AzureSky.fedora@gmail.com>
 *      
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */

#ifndef _PROC_VIEW_H_
#define _PROC_VIEW_H_

#include <glibmm.h>
#include <gtkmm.h>
#include <unistd.h>
#include <sstream>
#include <string>
#include <cstdio>
#include "../lib/proc_list.h"

class proc_view : public Gtk::TreeView
{
	public:
		proc_view(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& refGlade);
		~proc_view();
		const Glib::RefPtr<Gtk::Builder>& refXml;
		void proc_refresh();
	private:
		void init_view();
		void proc_title();
		void proc_read();
		std::string char_to_state(char);
		void add_row(std::list<struct proc_link>::iterator);
		class proc_tree : public Gtk::TreeModel::ColumnRecord
  		{
  			public:
				proc_tree(){ 
					add (m_comm); 
					add (m_stat);
					add (m_pid);
					add (m_uid);
					add (m_mem);
				}

    				Gtk::TreeModelColumn<std::string> m_comm;
    				Gtk::TreeModelColumn<std::string> m_stat;
    				Gtk::TreeModelColumn<unsigned int> m_pid;
    				Gtk::TreeModelColumn<unsigned int> m_uid;
    				Gtk::TreeModelColumn<unsigned long> m_mem;
  		};
		proc_tree proc_list;
		Glib::RefPtr<Gtk::ListStore> p_proc_model;

		class proc_list the_list;
		
		uid_t my_uid;
};
#endif //_PROC_VIEW_H_
